<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-form ref="form" :model="stock_house" :rules="rules" label-width="100px" id="mvcfm">
      <el-button @click="warehouseInputSubmit('')" type='success' size="mini"><i class='fa fa-check'></i>保存</el-button>
      <el-button @click="gotoPage('/psi/supplychainmana/WarehouseList2?'+vueparams+'')" type='primary' size="mini"><i class='fa fa-reply'></i>返回</el-button>
      <div class="form-unit">
        <span class="mvc-title-left"> 仓库区域增加 </span>
      </div>
      <div>
        <el-row>
          <el-col :span="12">
            <el-form-item label="仓库" prop="firm_id">
              <el-select style='width:100%' v-model="stock_house.firm_id" @change="list_s_firm">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in s_firm" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="区域" prop="layout_item_id">
              <el-select style='width:100%' v-model="stock_house.layout_item_id">
                <el-option label="－－无－－" value='' />
                <el-option v-for="dict in s_layout_item" :key="dict.__code" :label="dict.__desc" :value="dict.__code"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="仓库区域条形码" prop="hours_barcode">
              {{stock_house.hours_barcode}}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="仓库区域编号" prop="hours_num">
              <el-input v-model="stock_house.hours_num" />
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="仓库区域操作员" prop="operator_id">
              {{store_staff.operator_id}}
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div>
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input type="textarea" v-model="stock_house.remark" ttparea=350></el-input>
            </el-form-item>
          </el-col>
        </el-row>
      </div>
    </el-form>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'WarehouseInput',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        stock_house: {
          firm_id: null,
          layout_item_id: null,
          hours_barcode: null,
          hours_num: null,
        },
        store_staff: {
          operator_id: null,
          remark: null,
        },
        s_firm: [],
        s_layout_item: [],
        loading: false,
        rules: {
          firm_id: [{
            required: true,
            message: "仓库不能为空",
            trigger: 'blur',
          }],
          hours_num: [{
            required: true,
            message: "仓库区域编号不能为空",
            trigger: 'blur',
          }],
        }
      }
    },
    created() {
      this.getData();
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/supplychainmana/WarehouseInput/warehouseInput?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      warehouseInputSubmit(_params) {
        this.$refs["form"].validate(valid => {
          if (valid) {
            request({
              method: 'post',
              url: '/xcapi/VUEAction/psi/supplychainmana/WarehouseInput/warehouseInputSubmit?' + _params + this.vueparams,
              data: this.postData()
            }).then(data => {
              this.gotoPage("/psi/supplychainmana/WarehouseDet/warehouseDet?" + this.vueparams, data);
              this.msgSuccess(data.msg);
            })
          } else {
            this.msgError("必填项错误");
          }
        });
      },
      list_s_firm(value) {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/supplychainmana/WarehouseInput/ajaxList?' + this.vueparams,
          params: {
            htmltable: '',
            cfield_name: "layout_item_id",
            firm_id: value
          }
        }).then(data => {
          this.$set(this.stock_house, 'layout_item_id', '');
          this.s_layout_item = data['layout_item_id'];
        })
      },
    },
  }
</script>
